package edu.langnan.xiaoli.controller.common;

import edu.langnan.xiaoli.base.AjaxResult;
import edu.langnan.xiaoli.base.controller.BaseController;
import edu.langnan.xiaoli.base.entity.BaseEntity;
import edu.langnan.xiaoli.core.dto.ActivityDTO;
import edu.langnan.xiaoli.core.page.TableDataInfo;
import edu.langnan.xiaoli.service.ActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author cql
 */
@RestController
@RequestMapping("common/activity")
public class CommonActivityController extends BaseController {

    @Autowired
    private ActivityService activityService;

    /**
     * 分页获取活动列表(静态活动/动态活动)
     *
     * @param actType 0: 获取静态活动; 1: 获取动态活动; "": 获取所有
     * @return
     */
    @GetMapping("list")
    public TableDataInfo activityList(@RequestParam(value = "actType", defaultValue = "",required = false) String actType) {
        startPage();

        List<ActivityDTO> result = activityService.activityList(actType);

        return getDataTable(result);
    }


    /**
     * 根据活动编号查找活动信息
     *
     * @param activityId
     * @return
     */
    @GetMapping("{activityId}")
    public AjaxResult findActivityById(@PathVariable("activityId") Integer activityId) {
        ActivityDTO result = activityService.findActivityById(activityId);
        return AjaxResult.success(result);
    }


}
